<template>
	<view class="bookDetail">
		<div class="top">
			<span class="iconfont icon-zuojiantou" @click="go"></span>
			<span>{{detail.title}}</span>
			<span></span>
		</div>
		<div class="header">
			<div class="left">
				<img :src="detail.cover" alt="">
			</div>
			<div class="right">
				<p>{{detail.title}}</p>
				<p>
					<span>￥{{detail.price}}</span>
					<span>￥{{detail.t_price}}</span>
					<span>{{detail.sub_count}}人</span>
				</p>
			</div>
		</div>
		
		<ir-tabs :navs="navs" :multiple="true" @navChange="change">
		     <template v-slot:page1>
				<view class="tabs-top">
					<p>{{detail.title}}</p>
					<p>{{detail.sub_count}}人学过</p>
					<p>
						<span>￥{{detail.price}}</span>
						<s>￥{{detail.t_price}}</s>
					</p>
				</view>
				<view class="bottom">
					<p>电子书简介</p>
					<view class="text" v-html="detail.try">
					</view>
				</view>
		     </template>
		        
		     <template v-slot:page2>
					<div class="jie">共{{(detail.book_details).length}}节</div>
					<div class="content" v-for="(item,index) in book_details" :key="index" @click="gogo(item.id,item.title)">
						<div class="left">00{{item.orderby+1}}</div>
						<div class="right">
							<p>{{item.title}}</p>
							<p v-if="item.isfree==1">免费试看</p>
						</div>
					</div>
		    </template>
		</ir-tabs>
			<u-button type="success" :text="'立即订购￥'+detail.price" class="footer"></u-button>
	</view>
</template>

<script>
	import {getread} from "../request/index.js"
	export default {
		data() {
			return {
				detail:{},
				navs:['简介','目录'],
				book_details:[]
			}
		},
		methods: {
			go(){
				uni.navigateBack(1)
			},
			change(){
				
			},
			gogo(id,val){
				
				uni.navigateTo({
					url:`/pages/BookDetailsPages/BookDetailsPages?val=${val}+&book_id=${this.detail.id}+&id=${id}`
				})
			}
		},
		onLoad(options) {
			getread({id:options.id}).then(res=>{
				this.detail=res.data.data
				this.book_details=res.data.data.book_details
				console.log(res);
				console.log(this.book_details);
			})
			
		}
	}
</script>

<style lang="scss">
.bookDetail{
	width: 100%;
	height: 100%;
	position: absolute;
	.footer{
		position: fixed;
		bottom: 0;
		right: 0;
		height: 50px;
	}
	.bottom{
		width: 100%;
		line-height: 50px;
		font-size: 18px;
		padding: 0 10px;
		box-sizing: border-box;
		.text{
			border-top: 1px solid #f5f5f3;
			border-bottom: 1px solid #f5f5f3;
		}
	}
	.content{
		display: flex;
		height: 82px;
		align-items: center;
		border-bottom: 1px solid #ccc;
		.left{
			width: 60px;
			text-align: center;
		}
		.right{
			flex: 1;
			
			p:nth-child(2){
				width: 80px;
				text-align: center;
				font-size: 14px;
				color: #dc3646;
				border: 1px solid #dc3646;
				border-radius: 5px;
			}
		}
	}
	.tabs-top{
		width: 100%;
		height: 100px;
		margin-top: 20px;
		border-bottom: 10px solid #f5f5f3;
		p{
			margin-top: 7px;
			margin-left: 10px;
			
		}
		p:nth-child(2){
			font-size: 16px;
			color: #a9a5a0;
		}
		p:nth-child(3){
			span{
				color: #dc3545;
				font-size: 25px;
			}
			s{
				color: #a9a5a0;
				font-size: 16px;
			}
		}
	}
	.top{
		width: 100%;
		height: 50px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		padding: 0 10px;
	}
	.header{
		width: 100%;
		height: 231px;
		display: flex;
		.left{
			flex: 4;
			img{
				width: 100%;
				height: 100%;
			}
		}
		.right{
			flex: 6;
			margin-left: 10px;
			// p:nth-child(1){
			// 	align-self: flex-start;
			// }
			p:nth-child(2){
				color: #dc3545;
				border: 1px solid #dc3545;
				width: 70%;
				background-color: #fff7f0;
				// opacity: 1;

				height: 50px;
				line-height: 50px;
				margin-top: 100px;
				span:nth-child(1){
					font-size: 20px;
				}
				span:nth-child(2){
					color: #ccc;
					font-size: 16px;
				}
			}
			
		}
	}
}
</style>
